#include <bits/stdc++.h>

using namespace std;

int col[100001],vis[100001];

struct comp{
    int val,num;
}com[10001];

int fast_read()
{
    char c;
    int f=1,x=0;
    c=getchar();
    while(c<'0'||c>'9')
    {
        if(c=='-') f=-1;
        c=getchar();
    }
    while(c>='0'&&c<='9')
    {
        x=x*10+(c-'0');
        c=getchar();
    }
    x*=f;
    return x;
}


int main()
{
    freopen("color.in","r",stdin);
    freopen("color.out","w",stdout);

    int t;
    scanf("%d",&t);
    while(t--)
    {
        int n,colour=1,tot=0;
        scanf("%d",&n);
        memset(com,0,sizeof(com));
        memset(vis,0,sizeof(vis));
        memset(col,0,sizeof(col));
        for(int i=1; i<=n; i++)
        {
            col[i]=fast_read();
            if(vis[col[i]])
            {
                com[++tot].val=col[i];
                com[tot].num++;
            }
            vis[col[i]]=1;
        }
        int ans=0;
        for(int i=1; i<=tot; i++)
        {
            int tmp=1;
            for(int j=1; j<=com[i].num; j++) tmp*=com[i].val;
            ans+=tmp;
        }
        printf("%d\n",ans);
    }


    return 0;
}
